<template>
	<view>
		<Home v-if="activeIndex === 0" />
		<Peripheral v-if="activeIndex === 1" :params="params" />
		<Service v-if="activeIndex === 2" />
		<Mine v-if="activeIndex === 3" />
		<ycy-tabbar v-model:activeIndex="activeIndex" />
	</view>
</template>

<script setup>
	import { ref, watch } from "vue";
  import { onLoad } from '@dcloudio/uni-app';
	import Home from '@/pages/home/home.vue';
	import Peripheral from '@/pages/peripheral/peripheral.vue';
	import Service from '@/pages/service/service.vue';
	import Mine from '@/pages/mine/mine.vue';

  onLoad(options => {
    console.log('onLoad', options);
    if (options.indexPageActive) activeIndex.value = Number(options.indexPageActive);
    const temp = Object.assign({}, options);
    Reflect.deleteProperty(temp, 'indexPageActive');
    params.value = temp;
  })

  watch(() => activeIndex, (newVal, oldVal) => {
    if (oldVal === 1) params.value = {}
  })
	
	const activeIndex = ref(0);
  const params = ref({});
</script>
